﻿using IBll;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Model;
using NPOI.SS.Formula.Functions;

namespace WebApl.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class HelteController : ControllerBase, IHeltebLL
    {

         

        public HelteController(IHeltebLL bll,ILogger<HelteController> logger)
        {
            Bll = bll;
            Logger = logger;
        }

        public IHeltebLL Bll { get; }
        public ILogger<HelteController> Logger { get; }

        /// <summary>
        /// 新增食谱
        /// </summary>
        /// <param name="t">数据信息</param>
        /// <returns>返回值受影响行数</returns>
        /// 
        [HttpPost]
        public Task<int> AddAnync(Helte helte)
        {
            try//异常处理
            {
                Logger.LogInformation($"{helte}添加一条信息");
                  return Bll.AddAnync (helte);
            }
            catch (Exception)
            {

                throw;
            }
        }
        /// <summary>
        /// 显示查询
        /// </summary>
        /// <param name="name">食谱标题模糊</param>
        /// <param name="helteTypeId">分类下拉框</param>
        /// <returns>通过食谱，分类下拉框查询数据</returns>
        /// 
        [HttpGet]
        public dynamic ShowHelte(string? name, int helteTypeId)
        {
            try//异常处理
            {
                Logger.LogInformation("查询一条信息");
                return Bll.ShowHelte (name, helteTypeId);
            }
            catch (Exception)
            {

                throw;
            }
           
        }
    }
}
